package BSQX_Bit;

import java.util.*;

public class BSQX_3_24 {

    /*想了1个半小时想不出来,以后半个小时后没思路的直接不做了
    * 草:服了 做了一个多小时结果发现看错题目了,真操蛋啊!!!!!*/
    /*public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int k=W>H?H:W;
        System.out.println(2*k);

    }
    public static String fun2(int x,int y){
       StringBuilder stringBuilder=new StringBuilder();
       stringBuilder.append(x);
       stringBuilder.append(y);
        return stringBuilder.toString();
    }
    public static   int No_Two(int W,int H){
        *//*首先这是一个二维数组
        * 条件 欧几里得距离=(x1-x2)^2+(y1-y2)^2 != 2
        * 回溯?
        * 条件- X 与 X相差 1 , Y 和 Y相差1
        * 如果我能算出来 有多少相等的,然后用矩阵格子总数减去相等,是不是就是答案?*//*
        int count=0;
        HashMap<String,Boolean> hashMap=new HashMap<>();//用来存放被距离的
        for (int i = 0; i < W; i++) {
            for (int j = 0; j < H; j++) {
               String s1=fun2(i,j);
                if (!hashMap.containsKey(s1)){
                    String s2=fun2(i-1,j+1);
                    String s3=fun2(i+1,j-1);

                    if (hashMap.get(s2) && i-1 >= 0 && j+1 < H)
                }
                if (hashMap.get(stringBuilder.toString()) != null && hashMap.get(stringBuilder.toString()) == false){
                    continue;
                }else {
                    hashMap.put(stringBuilder.toString(),true);
                    StringBuilder stringBuilder1=new StringBuilder();
                    StringBuilder stringBuilder2=new StringBuilder();
                    stringBuilder1.append(i-1);
                    stringBuilder1.append(j+1);
                    stringBuilder2.append(i+1);
                    stringBuilder2.append(j-1);
                    hashMap.put(stringBuilder1.toString(), false);
                    hashMap.put(stringBuilder2.toString(), false);
                    count++;
                }
            }
        }
        return count;
    }*/


    public static int StrToInt(String str) {
        /* 解题思路
         字符串转成整数,我直接用字符串int强转-不行
         那么只能用字符了,字符(int)转过来是ASCII表的值
         考虑边界问题:也就是int能表示的最大值是多少,换句话说就是这个字符串是否合法
           还得考虑负数情况*/
        if (str == null){
            return 0;
        }
        int count=0;
        int Max=Integer.MAX_VALUE;
        long count2=0;
        char[] chars=str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] >= '0' && chars[i] <= '9'){
                if (count2 < Max){
                    count = count*10+(int)(chars[i]-48);
                    count2 = count2*10+(int)(chars[i]-48);
                }else {
                    return 0;
                }
            }else if (chars[0] == '+' || chars[0] == '/' || chars[0] == '-'){
                continue;
            }else {
                return 0;
            }
        }
        if (count != 0 &&chars[0] == '-'){
            count*=-1;
        }
        return count;
    }



    public static void main1(String[] args) {
        int num=10;
        long test=012;
        System.out.println(test(10));
    }
    public static int test(int b){
        try {
            b+=10;
            return b;
        }catch (RuntimeException e){

        }catch (Exception e){

        }finally {
            b+=10;
            return b;
        }
    }
}
